package com.fourgirls.xiaoxiang.controller;

import com.fourgirls.xiaoxiang.exception.Result;
import com.fourgirls.xiaoxiang.pojo.Address.UserNameAddressVo;
import com.fourgirls.xiaoxiang.service.Address.UserAddressService;
import com.fourgirls.xiaoxiang.util.JwtUtils;
import com.fourgirls.xiaoxiang.util.Login;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;

@RestController
@CrossOrigin
public class AddressController {

    @Autowired
    UserAddressService userAddressService;

    @Autowired
    JwtUtils jwtUtils;

    //---------------------------------------------------------------查询分割线--------------------------------------------------------

    /**
     * 查询address表中的所有数据(一对多的级联，查询user表中用户对应的收货地址)
     *
     * @return 查询的数据
     */
    @Login
    @RequestMapping("findAllUserAddress")
    public Result findAllUserAddress(@RequestBody UserNameAddressVo userNameAddressVo) {
        System.out.println(userAddressService.findAllUserAddresss(userNameAddressVo));
        return Result.ok().put("data", userAddressService.findAllUserAddresss(userNameAddressVo));
    }
}
